home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / OTHER_LA / QUINTA / FIT.Q < prev    next >
Text File  |  1990-03-22  |  684b  |  28 lines

  1. ;
  2. ; This is an example of a curve fit using Quinta.  The message polyfit
  3. ; accepts an integer and a matrix of points.  The matrix must be of
  4. ; dimensions n by 2, where each row of the matrix is a data point, the
  5. ; x coordinates in column 1.  The integer argument is the order of the
  6. ; desired polynomial.  The example below requests the polynomial of
  7. ; order 2 which best fits the 4 data points (-2,6) (-1,0) (1,8) (2,17).
  8. ;
  9.  
  10. 2
  11.  
  12. -2 6 -1 0 1 8 2 17 4 2 >dim >mat
  13.  
  14. polyfit
  15.  
  16. print
  17.  
  18. ; The resulting matrix is indicated below.  This means that the best
  19. ; fit 2nd order polynomial (in x) for the above data points is:
  20.  
  21. ; 1.5 + 3x + (2.5)x^2
  22.  
  23. ;     | 1.5   |
  24. ;     | 3   |
  25. ;     | 2.5   |
  26.  
  27.  
  28.